package org.fastsyncer.manager.listener.mysql.binlog.impl.event;

import java.util.List;

import org.fastsyncer.manager.listener.mysql.binlog.BinlogEventV4Header;
import org.fastsyncer.manager.listener.mysql.common.glossary.Pair;
import org.fastsyncer.manager.listener.mysql.common.glossary.Row;
import org.fastsyncer.manager.listener.mysql.common.glossary.UnsignedLong;
import org.fastsyncer.manager.listener.mysql.common.glossary.column.BitColumn;
import org.fastsyncer.manager.listener.mysql.common.util.MySQLConstants;
import org.fastsyncer.manager.listener.mysql.common.util.ToStringBuilder;

/**
 * Used for row-based binary logging. This event logs updates of rows in a single table.
 * @ClassName: UpdateRowsEvent 
 * @author: AE86
 * @date: 2018年10月17日 下午2:30:06
 */
public final class UpdateRowsEvent extends AbstractRowEvent {
	public static final int EVENT_TYPE = MySQLConstants.UPDATE_ROWS_EVENT;

	private UnsignedLong columnCount;
	private BitColumn usedColumnsBefore;
	private BitColumn usedColumnsAfter;
	private List<Pair<Row>> rows;

	public UpdateRowsEvent() {
	}

	public UpdateRowsEvent(BinlogEventV4Header header) {
		this.header = header;
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this)
		.append("header", header)
		.append("tableId", tableId)
		.append("reserved", reserved)
		.append("columnCount", columnCount)
		.append("usedColumnsBefore", usedColumnsBefore)
		.append("usedColumnsAfter", usedColumnsAfter)
		.append("rows", rows).toString();
	}

	public UnsignedLong getColumnCount() {
		return columnCount;
	}

	public void setColumnCount(UnsignedLong columnCount) {
		this.columnCount = columnCount;
	}

	public BitColumn getUsedColumnsBefore() {
		return usedColumnsBefore;
	}

	public void setUsedColumnsBefore(BitColumn usedColumnsBefore) {
		this.usedColumnsBefore = usedColumnsBefore;
	}

	public BitColumn getUsedColumnsAfter() {
		return usedColumnsAfter;
	}

	public void setUsedColumnsAfter(BitColumn usedColumnsAfter) {
		this.usedColumnsAfter = usedColumnsAfter;
	}

	public List<Pair<Row>> getRows() {
		return rows;
	}

	public void setRows(List<Pair<Row>> rows) {
		this.rows = rows;
	}
}
